# Maintainer: Orhun Parmaksız <orhun@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Filipe Nascimento <flipee at tuta dot io>
# Contributor: Attenuation <ouyangjun1999@gmail.com>

pkgname=procs
pkgver=0.14.4
pkgrel=1
pkgdesc="A modern replacement for ps written in Rust"
arch=('loong64' 'x86_64')
url="https://github.com/dalance/procs"
license=('MIT')
depends=('gcc-libs')
makedepends=('cargo')
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
sha256sums=('77c5f5d3bdfc9cef870732500ef58c203a1464f924b12f79c7d9e301b4dd5b16')

prepare() {
    cd "$pkgname-$pkgver"
#    cargo fetch --target "`uname -m`-unknown-linux-gnu"
}

build() {
    cd "$pkgname-$pkgver"
    find -name Cargo.lock -exec rm -f {} \;
    mkdir -p .cargo
    cat > .cargo/config.toml <<EOF
[source.crates-io]
registry = "https://gitee.com/yetist/crates.io-index"
EOF
    cargo build --release

    "target/release/$pkgname" --gen-completion zsh
    "target/release/$pkgname" --gen-completion bash
    "target/release/$pkgname" --gen-completion fish
}

check() {
    cd "$pkgname-$pkgver"
    cargo test --frozen
}

package() {
    cd "$pkgname-$pkgver"
    install -Dm 755 "target/release/$pkgname" -t "$pkgdir/usr/bin"
    install -Dm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
    install -Dm 644 "_$pkgname" -t "$pkgdir/usr/share/zsh/site-functions"
    install -Dm 644 "$pkgname.bash" "$pkgdir/usr/share/bash-completion/completions/$pkgname"
    install -Dm 644 "$pkgname.fish" -t "$pkgdir/usr/share/fish/vendor_completions.d"
}

# vim: ts=2 sw=2 et:
